package com.xms.security.service.principal;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xms.core.module.ModuleCollection;
import com.xms.schema.core.AttributeDefaults;
import com.xms.security.data.SystemUserPermissionMapper;
import com.xms.security.entity.Privilege;
import com.xms.security.entity.UserPrivilege;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * <p>
 * SystemUserPermissionService
 * </p>
 *
 * @author migo
 * @since 2021/9/4
 */
@Service
public class SystemUserPermissionService extends ServiceImpl<SystemUserPermissionMapper, UserPrivilege> implements ISystemUserPermissionService{

    @Override
    public Privilege getAuthPrivilege(UUID systemUserId, String areaName, String className, String methodName) {
        return super.getBaseMapper().getAuthPrivilege(systemUserId,areaName, className, methodName, ModuleCollection.getIdentity("menu"));
    }

    @Override
    public Privilege getAuthPrivilege(UUID systemUserId, String url) {
        return super.getBaseMapper().getAuthPrivilegeByUrl(systemUserId, url, ModuleCollection.getIdentity("menu"));
    }

    @Override
    public List<UUID> getNoneReadFields(UUID systemUserId, List<UUID> securityFields) {
        return super.getBaseMapper().getNoneReadFields(systemUserId, securityFields, ModuleCollection.getIdentity(AttributeDefaults.MODULE_NAME));
    }

    @Override
    public List<UUID> getNoneEditFields(UUID systemUserId, List<UUID> securityFields) {
        return super.getBaseMapper().getNoneEditFields(systemUserId, securityFields,ModuleCollection.getIdentity(AttributeDefaults.MODULE_NAME));
    }

    @Override
    public List<Privilege> getPrivileges(UUID systemUserId) {
        return super.getBaseMapper().getPrivileges(systemUserId, ModuleCollection.getIdentity("menu"));
    }
}
